package com.excilys.model;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.ui.Model;

/**
 * Object class that helps to instantiate the logbar
 * 
 * @author excilys dev : GF
 * 
 */
public class Logbar {

	/**
	 * Sets up the logbar 'username' parameter
	 * 
	 * @param model
	 */
	public void setContent(Model model) {
		SecurityContext ctx = SecurityContextHolder.getContext();
		Authentication auth = ctx.getAuthentication();
		String username = auth.getName();
		model.addAttribute("username", username);
	}

}
